package org.example.library.config;

import org.example.library.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

import java.util.Arrays;
import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    private List<String> excludePath = Arrays.asList("/user/login",
            "/**/*.html",
            "/css/**",
            "/js/**",
            "/pic/**",
            "/test/**",
            "/**/*.ico");
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截所有路径
                .excludePathPatterns(excludePath); //排除一些路径
    }
}
